package SinglePattern.LazyModel;

/**
 * 懒汉式，线程安全：
 * 必须加锁 synchronized 才能保证单例，但加锁会影响效率。
 * @author
 * @create 2018-10-18 11:09
 **/
public class LazyModel {
    private static LazyModel instance;

    private LazyModel() {
    }

    public static synchronized LazyModel getInstance() {
        if (instance == null) {
            instance = new LazyModel();
        }
        return instance;
    }

    public void lazyModelHello() {

        System.out.println("lazyMode Hello!");
    }
}
